# -*- coding: utf-8 -*-
from src.com.ydzy.util.base_util import BaserUtil
from src.com.ydzy.util.sql_util import MySQLUtils

db = MySQLUtils('192.168.8.234', 3306, 'root', 'root', 'audit_local')
base_client=BaserUtil()

def obtain_table_columns(table):
    columns = db.retrieve_columns(table=table)
    # columns = [db.converter.snake_to_camel(item) for item in columns]
    return columns

def obtain_cloumn_getter(key, pre=None):
    if not base_client.is_empty(pre):
        return pre+'get' + base_client.capitalize_first_letter(key) + "()"
    return 'get'+base_client.capitalize_first_letter(key)+"()"


def obtain_tables_getter(tables,pre=None):
    table_dict={}
    for table in tables:
        getters=[]
        columns = obtain_table_columns(table)
        # tt=['"'+item+'"' for item in columns]
        tt=[item for item in columns]
        print(",".join(tt))
        for column in columns:
            if 'id'==column:
                continue
            tmp_getter=obtain_cloumn_getter(column, pre)
            getters.append(tmp_getter)
        table_dict[table]=getters
    return table_dict


tables=['audit_service_config']
table_dict=obtain_tables_getter(tables,'entity.')

for k,v in table_dict.items():
    print(k)
    print(", ".join(v))
    print("----------------------------------------------华丽的分割线----------------------------------------------")